package com.lp.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

// 事务
@EnableTransactionManagement
@Configuration
@MapperScan(basePackages = "com.lp.mysqlmybatisplus.dao")
public class MyMapperConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        PaginationInnerInterceptor paginationIn = new PaginationInnerInterceptor(DbType.MYSQL);
        paginationIn.setOverflow(true);
        paginationIn.setMaxLimit(1000L);
        interceptor.addInnerInterceptor(paginationIn);
        return interceptor;
    }
}
